import 'package:bxultimate/data/request/user_request.dart';
import 'package:get/get.dart';

import 'state.dart';

class MyOrderListController extends GetxController {
  final MyOrderListState state = MyOrderListState();
  var pageSize = 10;

  @override
  void onInit() {
    // TODO: implement onInit
    super.onInit();

    getData(false);
  }


  getData(bool isClear) async {
    var list = await UserRequest.getMyOrderList(state.page,pageSize);
    if(isClear){
      state.orderList = list;
    }else{
      state.orderList.addAll(list);
    }
    update();
  }

  Future<void> onRefresh() async {
    state.page = 1;
    await getData(true);
  }

  Future<void> onLoad() async {
    state.page++;
    await getData(false);
  }

}
